import numpy as np

class mask_matrix():

    def __init__(self):

        self.intent = {"国际件":0,"业务咨询":1,"查单":2,"下单":3}
        self.sub_task = {"业务咨询":0,"国际件产品名称":1,"反馈需求":2,"是否满足需求":3,"咨询产品":4,"咨询类型":5,"查单伴随需求":6,
                         "下单产品名称":7,"下单结果":8,"下单伴随需求":9}
        self.sub_task_detail = {}
        self.sub_task_detail["国际件"] = {}
        self.sub_task_detail["国际件"]["业务咨询"] = {"国际件":0,"业务咨询":1,"查单":2,"下单":3}
        self.sub_task_detail["国际件"]["产品名称"] = {"标快+":4,"国际特惠":5,"其他":6,"国际标快":7}
        self.sub_task_detail["国际件"]["反馈需求"] = {"托寄物及其他":8,"时效慢":9,"清关":10,"流向少":11,"运费贵":12,"空":13,"税费":14}
        self.sub_task_detail["业务咨询"] = {}
        self.sub_task_detail["业务咨询"]["是否满足需求"] = {"可以满足":15,"不能满足":16,"空":17}
        self.sub_task_detail["业务咨询"]["咨询产品"] = {"时令水果":18,"其他产品":19,"其他":19,"顺丰特惠":20,"顺丰标快":21,
                                                "顺丰即日":22,"海鲜水产":23,
                                        "重货包裹":24,"顺丰次晨":25,"空":26}
        self.sub_task_detail["业务咨询"]["咨询类型"] = {"收派员信息":27,"运费/重量/体积":28,"微信":29,"托寄物品标准":30,"月结咨询":31,
                                        "截单时间":32,"快件时效":33,"其他":34,"空":35,"发票配给":36,"代收货款":37,"保价":38,
                                        "服务范围":39,"其他各服务热线":40,"营业网点信息":41}
        self.sub_task_detail["查单"] = {}
        self.sub_task_detail["查单"]["查单伴随需求"] = {"时效":42,"咨询其他":43,"快件查询":44,"其他":45,"收派员、网点信息":46,
                                                "修改收寄方信息":47,"空":48,"无单号查单":49}
        self.sub_task_detail["下单"] = {}
        self.sub_task_detail["下单"]["产品名称"] = {"顺丰标快":50,"无具体产品名称":51,"其他":52}
        self.sub_task_detail["下单"]["下单结果"] = {"成功下单_客户不满意":53,"其他":54,"未成功下单-客户咨询":55,"成功下单":56,
                                              "未成功下单-客户不满意/我司未满足":57}
        self.sub_task_detail["下单"]["下单伴随需求"] = {"咨询产品时效":58,"其他":59,"咨询产品价格":60,"未咨询仅下单":61,"空":62,
                                                "咨询产品流向/服务范围":63}

        self.get_mask_matrix()


    def get_mask_matrix(self):

        #一个掩码矩阵，用于进行任务的规划
        self.sub_mask = np.zeros((4,10))
        self.detail_mask = np.zeros((10,64))

        for key in self.sub_task_detail.keys():
            sub_dic = self.sub_task_detail[key]
            for sub_key in sub_dic:
                x1 = self.intent[key]

                if sub_key == '产品名称':
                    sub_key_alter = key + sub_key
                else:
                    sub_key_alter = sub_key

                y1 = self.sub_task[sub_key_alter]
                self.sub_mask[x1][y1] = 1
                detail_dic = sub_dic[sub_key]
                for detai_key in detail_dic:
                    z1 = detail_dic[detai_key]
                    self.detail_mask[y1][z1] = 1
